]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/entry: Fix primary/secondary icon leak
authorSebastian Keller <skeller@gnome.org>
Sat, 28 Feb 2026 21:26:15 +0000 (22:26 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 2 Mar 2026 01:35:12 +0000 (01:35 +0000)
_st_entry_set_icon() takes a ref when setting the primary/secondary
icon, but the ref is not removed when unsetting the icon or the entry is
destroyed.

Since clutter_actor_add_child() already adds a ref to the icon, there is
actually no need to manually add another ref. So stop doing that to fix
this leak.

This however also requires that StPasswordEntry takes ownership of its
own icon that it may set or unset multiple times. Since it is initially
floating we need to sink the ref for that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4095>

src/st/st-entry.c
src/st/st-password-entry.c

index d00bee6b7302be243e19f8065238ce55039a4fe8..cf13331b3bb2f6d82738df7024e2e387f68b0711 100644 (file)
@@ -1301,7 +1301,7 @@ _st_entry_set_icon (StEntry       *entry,
     {
       ClutterAction *click_gesture;
 
-      *icon = g_object_ref (new_icon);
+      *icon = new_icon;
 
       clutter_actor_set_reactive (*icon, TRUE);
       clutter_actor_add_child (CLUTTER_ACTOR (entry), *icon);
index 8c6204f37bd56e53356a05453dddcefbeb477701..df51b9fe39a980fc3eb1a81312cdebde6ee21c75 100644 (file)
@@ -224,6 +224,7 @@ st_password_entry_init (StPasswordEntry *entry)
                                            "style-class", "peek-password",
                                            "icon-name", "view-reveal-symbolic",
                                            NULL);
+  g_object_ref_sink (priv->peek_password_icon);
   st_entry_set_secondary_icon (ST_ENTRY (entry), priv->peek_password_icon);
 
   st_password_entry_set_show_peek_icon (entry, TRUE);